/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bsc.ejb.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;

/**
 *
 * @author memozac
 */
@Entity
public class ScoreDomain implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long idScoreDomain;

    @Column(columnDefinition="text")
    private String name;

    @ManyToMany(targetEntity=Person.class)
    @JoinTable(name="PersonScoreDomain",
    joinColumns=@JoinColumn(name="idScoreDomain"),
    inverseJoinColumns=@JoinColumn(name="idPerson"))
    private Collection<Person> persons;

    @OneToOne
    private ScoreView scoreView;

    public ScoreView getScoreView() {
        return scoreView;
    }

    public void setScoreView(ScoreView scoreView) {
        this.scoreView = scoreView;
    }
    /*@ManyToMany(targetEntity=ScoreCard.class)
    @JoinTable(name="ScoreCardDomain",
    joinColumns=@JoinColumn(name="idScoreDomain"),
    inverseJoinColumns=@JoinColumn(name="idScoreCard"))
    private Collection<ScoreCard> scoreCards;*/
    
    public Collection<Person> getPersons() {
        return persons;
    }

    public void setPersons(Collection<Person> persons) {
        this.persons = persons;
    }

    public Long getIdScoreDomain() {
        return idScoreDomain;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idScoreDomain != null ? idScoreDomain.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof ScoreDomain)) {
            return false;
        }
        ScoreDomain other = (ScoreDomain) object;
        if ((this.idScoreDomain == null && other.idScoreDomain != null) || (this.idScoreDomain != null && !this.idScoreDomain.equals(other.idScoreDomain))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bsc.ejb.entity.ScoreDomain[id=" + idScoreDomain + "]";
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

}//ends of class
